#ifndef __LF_BASE_H__
#define __LF_BASE_H__

#include "config.h"
#include "typedefs.h"

#if defined(__cplusplus)
extern "C"
{
#endif

#if (__OS_LINUX__)

#if defined(__x86_64__)
typedef int64u_t lf_atom_t;
#elif defined(__i686__)
typedef int32u_t lf_atom_t;
#endif

#define LF_INLINE inline

#define LF_ALIGN(alignment)         __attribute__( (aligned(alignment)) )

#if defined(__x86_64__)
#define LF_ALIGN_SINGLE_POINTER     8
#define LF_ALIGN_DOUBLE_POINTER     16
#elif defined(__i686__)
#define LF_ALIGN_SINGLE_POINTER     4
#define LF_ALIGN_DOUBLE_POINTER     8
#endif

#define LF_BARRIER_COMPILER_LOAD    __asm__ __volatile__ ( "" : : : "memory" )
#define LF_BARRIER_COMPILER_STORE   __asm__ __volatile__ ( "" : : : "memory" )
#define LF_BARRIER_COMPILER_FULL    __asm__ __volatile__ ( "" : : : "memory" )
#define LF_BARRIER_PROCESSOR_LOAD   __sync_synchronize()
#define LF_BARRIER_PROCESSOR_STORE  __sync_synchronize()
#define LF_BARRIER_PROCESSOR_FULL   __sync_synchronize()

#endif/* #if (__OS_LINUX__) */

#define LF_BARRIER_LOAD   LF_BARRIER_COMPILER_LOAD; LF_BARRIER_PROCESSOR_LOAD; LF_BARRIER_COMPILER_LOAD
#define LF_BARRIER_STORE  LF_BARRIER_COMPILER_STORE; LF_BARRIER_PROCESSOR_STORE; LF_BARRIER_COMPILER_STORE
#define LF_BARRIER_FULL   LF_BARRIER_COMPILER_FULL; LF_BARRIER_PROCESSOR_FULL; LF_BARRIER_COMPILER_FULL



#if defined(__cplusplus)
}
#endif

#endif/* __LF_BASE_H__ */
